package com.zs.grain.di.modules

import android.content.Context
import com.xnkj1688.semplibrary.entity.*
import dagger.Module
import dagger.Provides

/**
 * Created by Wesley on 2017/7/6.
 */

@Module
class GreenDaoModule {

    private var mDaoMaster: DaoMaster? = null

    @Provides
    internal fun provideDaoSession(context: Context): DaoSession {
        if (mDaoMaster == null) {
            val helper = DaoMaster.DevOpenHelper(context, if (ENCRYPTED) "xnxx-db-encrypted" else "xnxx")
            val db = if (ENCRYPTED) helper.getEncryptedWritableDb("super-secret") else helper.writableDb
            mDaoMaster = DaoMaster(db)
        }
        return mDaoMaster!!.newSession()
    }

    companion object {
        val ENCRYPTED = false
    }


}
